package com.javasist;

import javassist.*;

import java.lang.reflect.Modifier;

/**
 * Created by pengfei on 16/7/25.
 */
public class MyTranslator implements Translator {
    public void start(ClassPool pool)
            throws NotFoundException, CannotCompileException {}
    public void onLoad(ClassPool pool, String classname)
            throws NotFoundException, CannotCompileException
    {
        CtClass cc = pool.get(classname);
//        cc.setModifiers(Modifier.PUBLIC);
        System.out.println(11111);

        CtMethod cm = CtNewMethod.copy(cc.getMethod("toString",""),cc,null);
        cm.setBody("{System.out.println(\"我日你妈\")}");
        cc.addMethod(cm);

    }
}
